package com.zwj.batch.config.springBatch.decider;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
import org.springframework.batch.core.job.flow.JobExecutionDecider;

import java.util.Random;

/**
 * @author 张文接
 * @version 1.0
 * @createTime 2023/6/24 15:44
 */
public class BatchConfig13Decider implements JobExecutionDecider {

    @Override
    public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
        int ret = new Random().nextInt(3);
        String status = "D";
        switch (ret) {
            case 0:
                status = "A";
                break;
            case 1:
                status = "B";
                break;
            default:
                status = "C";
        }
        return new FlowExecutionStatus(status);
    }
}
